package org.zhangsh.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * </p>
 *
 * @author zhangsh
 * @version 1.0.0
 * @since 2019-04-18
 */
public final class InputUtil {

    private static final BufferedReader KEYBOARD_INPUT = new BufferedReader(new InputStreamReader(System.in));

    private InputUtil(){}

    public static String getInputString(String prompot) {

        String result = null;
        for(;;){

            System.err.print(prompot);
            try{
                result = KEYBOARD_INPUT.readLine();
            }catch (Exception e){
                e.printStackTrace();
                System.out.println("数据输入错误，该内容不允许为空");
            }
            if(result==null || "".equals(result)){
                System.out.println("数据输入错误，该内容不允许为空");
            }else{
               break;
            }
        }
        return result;
    }
}
